package test;

import test.impl.IfElseDemoFour;
import test.impl.IfElseDemoOne;
import test.impl.IfElseDemoThree;
import test.impl.IfElseDemoTow;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Jason Wilson
 * @description TODO
 * @date 2024-05-2024/5/11-13:46
 */
public class InsuranceCalculatorFactory {

    private static final Map<String, IfElseDemo> CALCULATOR_MAP = new HashMap<>();


    static {
        CALCULATOR_MAP.put("one", new IfElseDemoOne());
        CALCULATOR_MAP.put("tow", new IfElseDemoTow());
        CALCULATOR_MAP.put("three", new IfElseDemoThree());
        CALCULATOR_MAP.put("four", new IfElseDemoFour());
    }

    public static IfElseDemo getCalculator(BigDecimal income) {
        if (income.compareTo(BigDecimal.valueOf(1000)) <= 0) {
            return CALCULATOR_MAP.get("one");
        } else if (income.compareTo(BigDecimal.valueOf(2000)) <= 0) {
            return CALCULATOR_MAP.get("tow");
        } else if (income.compareTo(BigDecimal.valueOf(3000)) <= 0) {
            return CALCULATOR_MAP.get("three");
        } else {
            return CALCULATOR_MAP.get("four");
        }
    }

}
